﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace RLZY.DAL
{
	/// <summary>
	/// 数据访问类:GZ11
	/// </summary>
	public partial class GZ11
	{
		public GZ11()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(RLZY.Model.GZ11 model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into GZ11(");
			strSql.Append("用工性质,人数,技能工资,岗位工资,绩效工资,三项补贴,回贴,工龄津贴,职称津贴,特岗津贴,行车工津贴,星级津贴,车贴,五项津贴,卫生纸费,中晚班费,加班工资,补发,扣事假工资,扣病假工资,其它扣款,应发总额,扣失业保险,扣养老金,扣医疗保险,扣公积金,扣电视费,扣治安费,扣会费,扣互助金,扣丧葬费,五项扣款,实发金额)");
			strSql.Append(" values (");
			strSql.Append("@用工性质,@人数,@技能工资,@岗位工资,@绩效工资,@三项补贴,@回贴,@工龄津贴,@职称津贴,@特岗津贴,@行车工津贴,@星级津贴,@车贴,@五项津贴,@卫生纸费,@中晚班费,@加班工资,@补发,@扣事假工资,@扣病假工资,@其它扣款,@应发总额,@扣失业保险,@扣养老金,@扣医疗保险,@扣公积金,@扣电视费,@扣治安费,@扣会费,@扣互助金,@扣丧葬费,@五项扣款,@实发金额)");
			SqlParameter[] parameters = {
					new SqlParameter("@用工性质", SqlDbType.NVarChar,10),
					new SqlParameter("@人数", SqlDbType.Int,4),
					new SqlParameter("@技能工资", SqlDbType.Int,4),
					new SqlParameter("@岗位工资", SqlDbType.Int,4),
					new SqlParameter("@绩效工资", SqlDbType.Int,4),
					new SqlParameter("@三项补贴", SqlDbType.Decimal,17),
					new SqlParameter("@回贴", SqlDbType.Int,4),
					new SqlParameter("@工龄津贴", SqlDbType.Int,4),
					new SqlParameter("@职称津贴", SqlDbType.Int,4),
					new SqlParameter("@特岗津贴", SqlDbType.Int,4),
					new SqlParameter("@行车工津贴", SqlDbType.Int,4),
					new SqlParameter("@星级津贴", SqlDbType.Int,4),
					new SqlParameter("@车贴", SqlDbType.Int,4),
					new SqlParameter("@五项津贴", SqlDbType.Int,4),
					new SqlParameter("@卫生纸费", SqlDbType.Int,4),
					new SqlParameter("@中晚班费", SqlDbType.Decimal,17),
					new SqlParameter("@加班工资", SqlDbType.Decimal,17),
					new SqlParameter("@补发", SqlDbType.Decimal,17),
					new SqlParameter("@扣事假工资", SqlDbType.Decimal,17),
					new SqlParameter("@扣病假工资", SqlDbType.Decimal,17),
					new SqlParameter("@其它扣款", SqlDbType.Decimal,17),
					new SqlParameter("@应发总额", SqlDbType.Decimal,17),
					new SqlParameter("@扣失业保险", SqlDbType.Decimal,17),
					new SqlParameter("@扣养老金", SqlDbType.Decimal,17),
					new SqlParameter("@扣医疗保险", SqlDbType.Decimal,17),
					new SqlParameter("@扣公积金", SqlDbType.Int,4),
					new SqlParameter("@扣电视费", SqlDbType.Int,4),
					new SqlParameter("@扣治安费", SqlDbType.Int,4),
					new SqlParameter("@扣会费", SqlDbType.Decimal,17),
					new SqlParameter("@扣互助金", SqlDbType.Int,4),
					new SqlParameter("@扣丧葬费", SqlDbType.Int,4),
					new SqlParameter("@五项扣款", SqlDbType.Decimal,17),
					new SqlParameter("@实发金额", SqlDbType.Decimal,17)};
			parameters[0].Value = model.用工性质;
			parameters[1].Value = model.人数;
			parameters[2].Value = model.技能工资;
			parameters[3].Value = model.岗位工资;
			parameters[4].Value = model.绩效工资;
			parameters[5].Value = model.三项补贴;
			parameters[6].Value = model.回贴;
			parameters[7].Value = model.工龄津贴;
			parameters[8].Value = model.职称津贴;
			parameters[9].Value = model.特岗津贴;
			parameters[10].Value = model.行车工津贴;
			parameters[11].Value = model.星级津贴;
			parameters[12].Value = model.车贴;
			parameters[13].Value = model.五项津贴;
			parameters[14].Value = model.卫生纸费;
			parameters[15].Value = model.中晚班费;
			parameters[16].Value = model.加班工资;
			parameters[17].Value = model.补发;
			parameters[18].Value = model.扣事假工资;
			parameters[19].Value = model.扣病假工资;
			parameters[20].Value = model.其它扣款;
			parameters[21].Value = model.应发总额;
			parameters[22].Value = model.扣失业保险;
			parameters[23].Value = model.扣养老金;
			parameters[24].Value = model.扣医疗保险;
			parameters[25].Value = model.扣公积金;
			parameters[26].Value = model.扣电视费;
			parameters[27].Value = model.扣治安费;
			parameters[28].Value = model.扣会费;
			parameters[29].Value = model.扣互助金;
			parameters[30].Value = model.扣丧葬费;
			parameters[31].Value = model.五项扣款;
			parameters[32].Value = model.实发金额;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(RLZY.Model.GZ11 model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update GZ11 set ");
			strSql.Append("用工性质=@用工性质,");
			strSql.Append("人数=@人数,");
			strSql.Append("技能工资=@技能工资,");
			strSql.Append("岗位工资=@岗位工资,");
			strSql.Append("绩效工资=@绩效工资,");
			strSql.Append("三项补贴=@三项补贴,");
			strSql.Append("回贴=@回贴,");
			strSql.Append("工龄津贴=@工龄津贴,");
			strSql.Append("职称津贴=@职称津贴,");
			strSql.Append("特岗津贴=@特岗津贴,");
			strSql.Append("行车工津贴=@行车工津贴,");
			strSql.Append("星级津贴=@星级津贴,");
			strSql.Append("车贴=@车贴,");
			strSql.Append("五项津贴=@五项津贴,");
			strSql.Append("卫生纸费=@卫生纸费,");
			strSql.Append("中晚班费=@中晚班费,");
			strSql.Append("加班工资=@加班工资,");
			strSql.Append("补发=@补发,");
			strSql.Append("扣事假工资=@扣事假工资,");
			strSql.Append("扣病假工资=@扣病假工资,");
			strSql.Append("其它扣款=@其它扣款,");
			strSql.Append("应发总额=@应发总额,");
			strSql.Append("扣失业保险=@扣失业保险,");
			strSql.Append("扣养老金=@扣养老金,");
			strSql.Append("扣医疗保险=@扣医疗保险,");
			strSql.Append("扣公积金=@扣公积金,");
			strSql.Append("扣电视费=@扣电视费,");
			strSql.Append("扣治安费=@扣治安费,");
			strSql.Append("扣会费=@扣会费,");
			strSql.Append("扣互助金=@扣互助金,");
			strSql.Append("扣丧葬费=@扣丧葬费,");
			strSql.Append("五项扣款=@五项扣款,");
			strSql.Append("实发金额=@实发金额");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
					new SqlParameter("@用工性质", SqlDbType.NVarChar,10),
					new SqlParameter("@人数", SqlDbType.Int,4),
					new SqlParameter("@技能工资", SqlDbType.Int,4),
					new SqlParameter("@岗位工资", SqlDbType.Int,4),
					new SqlParameter("@绩效工资", SqlDbType.Int,4),
					new SqlParameter("@三项补贴", SqlDbType.Decimal,17),
					new SqlParameter("@回贴", SqlDbType.Int,4),
					new SqlParameter("@工龄津贴", SqlDbType.Int,4),
					new SqlParameter("@职称津贴", SqlDbType.Int,4),
					new SqlParameter("@特岗津贴", SqlDbType.Int,4),
					new SqlParameter("@行车工津贴", SqlDbType.Int,4),
					new SqlParameter("@星级津贴", SqlDbType.Int,4),
					new SqlParameter("@车贴", SqlDbType.Int,4),
					new SqlParameter("@五项津贴", SqlDbType.Int,4),
					new SqlParameter("@卫生纸费", SqlDbType.Int,4),
					new SqlParameter("@中晚班费", SqlDbType.Decimal,17),
					new SqlParameter("@加班工资", SqlDbType.Decimal,17),
					new SqlParameter("@补发", SqlDbType.Decimal,17),
					new SqlParameter("@扣事假工资", SqlDbType.Decimal,17),
					new SqlParameter("@扣病假工资", SqlDbType.Decimal,17),
					new SqlParameter("@其它扣款", SqlDbType.Decimal,17),
					new SqlParameter("@应发总额", SqlDbType.Decimal,17),
					new SqlParameter("@扣失业保险", SqlDbType.Decimal,17),
					new SqlParameter("@扣养老金", SqlDbType.Decimal,17),
					new SqlParameter("@扣医疗保险", SqlDbType.Decimal,17),
					new SqlParameter("@扣公积金", SqlDbType.Int,4),
					new SqlParameter("@扣电视费", SqlDbType.Int,4),
					new SqlParameter("@扣治安费", SqlDbType.Int,4),
					new SqlParameter("@扣会费", SqlDbType.Decimal,17),
					new SqlParameter("@扣互助金", SqlDbType.Int,4),
					new SqlParameter("@扣丧葬费", SqlDbType.Int,4),
					new SqlParameter("@五项扣款", SqlDbType.Decimal,17),
					new SqlParameter("@实发金额", SqlDbType.Decimal,17)};
			parameters[0].Value = model.用工性质;
			parameters[1].Value = model.人数;
			parameters[2].Value = model.技能工资;
			parameters[3].Value = model.岗位工资;
			parameters[4].Value = model.绩效工资;
			parameters[5].Value = model.三项补贴;
			parameters[6].Value = model.回贴;
			parameters[7].Value = model.工龄津贴;
			parameters[8].Value = model.职称津贴;
			parameters[9].Value = model.特岗津贴;
			parameters[10].Value = model.行车工津贴;
			parameters[11].Value = model.星级津贴;
			parameters[12].Value = model.车贴;
			parameters[13].Value = model.五项津贴;
			parameters[14].Value = model.卫生纸费;
			parameters[15].Value = model.中晚班费;
			parameters[16].Value = model.加班工资;
			parameters[17].Value = model.补发;
			parameters[18].Value = model.扣事假工资;
			parameters[19].Value = model.扣病假工资;
			parameters[20].Value = model.其它扣款;
			parameters[21].Value = model.应发总额;
			parameters[22].Value = model.扣失业保险;
			parameters[23].Value = model.扣养老金;
			parameters[24].Value = model.扣医疗保险;
			parameters[25].Value = model.扣公积金;
			parameters[26].Value = model.扣电视费;
			parameters[27].Value = model.扣治安费;
			parameters[28].Value = model.扣会费;
			parameters[29].Value = model.扣互助金;
			parameters[30].Value = model.扣丧葬费;
			parameters[31].Value = model.五项扣款;
			parameters[32].Value = model.实发金额;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from GZ11 ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
			};

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public RLZY.Model.GZ11 GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 用工性质,人数,技能工资,岗位工资,绩效工资,三项补贴,回贴,工龄津贴,职称津贴,特岗津贴,行车工津贴,星级津贴,车贴,五项津贴,卫生纸费,中晚班费,加班工资,补发,扣事假工资,扣病假工资,其它扣款,应发总额,扣失业保险,扣养老金,扣医疗保险,扣公积金,扣电视费,扣治安费,扣会费,扣互助金,扣丧葬费,五项扣款,实发金额 from GZ11 ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
			};

			RLZY.Model.GZ11 model=new RLZY.Model.GZ11();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public RLZY.Model.GZ11 DataRowToModel(DataRow row)
		{
			RLZY.Model.GZ11 model=new RLZY.Model.GZ11();
			if (row != null)
			{
				if(row["用工性质"]!=null)
				{
					model.用工性质=row["用工性质"].ToString();
				}
				if(row["人数"]!=null && row["人数"].ToString()!="")
				{
					model.人数=int.Parse(row["人数"].ToString());
				}
				if(row["技能工资"]!=null && row["技能工资"].ToString()!="")
				{
					model.技能工资=int.Parse(row["技能工资"].ToString());
				}
				if(row["岗位工资"]!=null && row["岗位工资"].ToString()!="")
				{
					model.岗位工资=int.Parse(row["岗位工资"].ToString());
				}
				if(row["绩效工资"]!=null && row["绩效工资"].ToString()!="")
				{
					model.绩效工资=int.Parse(row["绩效工资"].ToString());
				}
				if(row["三项补贴"]!=null && row["三项补贴"].ToString()!="")
				{
					model.三项补贴=decimal.Parse(row["三项补贴"].ToString());
				}
				if(row["回贴"]!=null && row["回贴"].ToString()!="")
				{
					model.回贴=int.Parse(row["回贴"].ToString());
				}
				if(row["工龄津贴"]!=null && row["工龄津贴"].ToString()!="")
				{
					model.工龄津贴=int.Parse(row["工龄津贴"].ToString());
				}
				if(row["职称津贴"]!=null && row["职称津贴"].ToString()!="")
				{
					model.职称津贴=int.Parse(row["职称津贴"].ToString());
				}
				if(row["特岗津贴"]!=null && row["特岗津贴"].ToString()!="")
				{
					model.特岗津贴=int.Parse(row["特岗津贴"].ToString());
				}
				if(row["行车工津贴"]!=null && row["行车工津贴"].ToString()!="")
				{
					model.行车工津贴=int.Parse(row["行车工津贴"].ToString());
				}
				if(row["星级津贴"]!=null && row["星级津贴"].ToString()!="")
				{
					model.星级津贴=int.Parse(row["星级津贴"].ToString());
				}
				if(row["车贴"]!=null && row["车贴"].ToString()!="")
				{
					model.车贴=int.Parse(row["车贴"].ToString());
				}
				if(row["五项津贴"]!=null && row["五项津贴"].ToString()!="")
				{
					model.五项津贴=int.Parse(row["五项津贴"].ToString());
				}
				if(row["卫生纸费"]!=null && row["卫生纸费"].ToString()!="")
				{
					model.卫生纸费=int.Parse(row["卫生纸费"].ToString());
				}
				if(row["中晚班费"]!=null && row["中晚班费"].ToString()!="")
				{
					model.中晚班费=decimal.Parse(row["中晚班费"].ToString());
				}
				if(row["加班工资"]!=null && row["加班工资"].ToString()!="")
				{
					model.加班工资=decimal.Parse(row["加班工资"].ToString());
				}
				if(row["补发"]!=null && row["补发"].ToString()!="")
				{
					model.补发=decimal.Parse(row["补发"].ToString());
				}
				if(row["扣事假工资"]!=null && row["扣事假工资"].ToString()!="")
				{
					model.扣事假工资=decimal.Parse(row["扣事假工资"].ToString());
				}
				if(row["扣病假工资"]!=null && row["扣病假工资"].ToString()!="")
				{
					model.扣病假工资=decimal.Parse(row["扣病假工资"].ToString());
				}
				if(row["其它扣款"]!=null && row["其它扣款"].ToString()!="")
				{
					model.其它扣款=decimal.Parse(row["其它扣款"].ToString());
				}
				if(row["应发总额"]!=null && row["应发总额"].ToString()!="")
				{
					model.应发总额=decimal.Parse(row["应发总额"].ToString());
				}
				if(row["扣失业保险"]!=null && row["扣失业保险"].ToString()!="")
				{
					model.扣失业保险=decimal.Parse(row["扣失业保险"].ToString());
				}
				if(row["扣养老金"]!=null && row["扣养老金"].ToString()!="")
				{
					model.扣养老金=decimal.Parse(row["扣养老金"].ToString());
				}
				if(row["扣医疗保险"]!=null && row["扣医疗保险"].ToString()!="")
				{
					model.扣医疗保险=decimal.Parse(row["扣医疗保险"].ToString());
				}
				if(row["扣公积金"]!=null && row["扣公积金"].ToString()!="")
				{
					model.扣公积金=int.Parse(row["扣公积金"].ToString());
				}
				if(row["扣电视费"]!=null && row["扣电视费"].ToString()!="")
				{
					model.扣电视费=int.Parse(row["扣电视费"].ToString());
				}
				if(row["扣治安费"]!=null && row["扣治安费"].ToString()!="")
				{
					model.扣治安费=int.Parse(row["扣治安费"].ToString());
				}
				if(row["扣会费"]!=null && row["扣会费"].ToString()!="")
				{
					model.扣会费=decimal.Parse(row["扣会费"].ToString());
				}
				if(row["扣互助金"]!=null && row["扣互助金"].ToString()!="")
				{
					model.扣互助金=int.Parse(row["扣互助金"].ToString());
				}
				if(row["扣丧葬费"]!=null && row["扣丧葬费"].ToString()!="")
				{
					model.扣丧葬费=int.Parse(row["扣丧葬费"].ToString());
				}
				if(row["五项扣款"]!=null && row["五项扣款"].ToString()!="")
				{
					model.五项扣款=decimal.Parse(row["五项扣款"].ToString());
				}
				if(row["实发金额"]!=null && row["实发金额"].ToString()!="")
				{
					model.实发金额=decimal.Parse(row["实发金额"].ToString());
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select 用工性质,人数,技能工资,岗位工资,绩效工资,三项补贴,回贴,工龄津贴,职称津贴,特岗津贴,行车工津贴,星级津贴,车贴,五项津贴,卫生纸费,中晚班费,加班工资,补发,扣事假工资,扣病假工资,其它扣款,应发总额,扣失业保险,扣养老金,扣医疗保险,扣公积金,扣电视费,扣治安费,扣会费,扣互助金,扣丧葬费,五项扣款,实发金额 ");
			strSql.Append(" FROM GZ11 ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" 用工性质,人数,技能工资,岗位工资,绩效工资,三项补贴,回贴,工龄津贴,职称津贴,特岗津贴,行车工津贴,星级津贴,车贴,五项津贴,卫生纸费,中晚班费,加班工资,补发,扣事假工资,扣病假工资,其它扣款,应发总额,扣失业保险,扣养老金,扣医疗保险,扣公积金,扣电视费,扣治安费,扣会费,扣互助金,扣丧葬费,五项扣款,实发金额 ");
			strSql.Append(" FROM GZ11 ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM GZ11 ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.ID desc");
			}
			strSql.Append(")AS Row, T.*  from GZ11 T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "GZ11";
			parameters[1].Value = "ID";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

